import { HomeOutlined } from '@ant-design/icons';
import { Button, message } from 'antd';
import { useEffect } from 'react';
import styles from './index.less';

export const ErrorPage = () => {
  useEffect(() => {
    const errorTime = localStorage.getItem('lastErrorTime');
    if (!errorTime || Date.now() - parseInt(errorTime) > 1000 * 60) {
      message.loading('正在重试');
      setTimeout(() => {
        localStorage.setItem('lastErrorTime', Date.now().toString());
        window.location.reload();
      }, 1000);
    }
  }, []);
  return (
    <div className={styles.container}>
      <img className={styles.img} src={require('../../assets/欢迎.png')} />
      {/* <h2 className={styles.title}>404</h2> */}
      <div className={styles.subtitle}>你访问的页面出错了</div>
      <div className={styles.extra}>
        <a href="/">
          <Button icon={<HomeOutlined />} type="primary">
            返回首页
          </Button>
        </a>
      </div>
    </div>
  );
};
